#include "EZ_Thread.h"


ez_thread_t task1;
ez_thread_t task2;
ez_thread_t task3;

ez_timer_t 	timer1;
ez_ipc_sem_t sem_global;
ez_memport_t	memport_global;
uint8_t	memport_buff[100];

uint32_t task1Env[1024];     
uint32_t task2Env[1024];
uint32_t task3Env[1024];

void delay (int count) 
{
    while (--count > 0);
}

int task1Flag;
void task1Entry (void * param) 
{
    for (;;) 
    {
        task1Flag = 1;
        delay(100);
        task1Flag = 0;
        delay(100);
    }
}

int task2Flag;
void task2Entry (void * param) 
{
		while(1)
		{
			task2Flag = 1;
			delay(100);
			task2Flag = 0;
			delay(100);
		}

}

int task3Flag;
void task3Entry (void * param) 
{
		while(1)
		{
			task3Flag = 1;
			delay(100);
			task3Flag = 0;
			delay(100);
		}

		
}

int idle3Flag;
void idleEntry (void * param) 
{

			idle3Flag = 1;
			delay(100);
			idle3Flag = 0;

}


int main () 
{
//		set_idle_callback(idleEntry);
		sem_object_init(&sem_global, 0);
		memPort_Init(&memport_global,memport_buff,6,10);
		timer_init(&timer1,10,idleEntry,0,EZ_TIMER_CYCLE);
	
		task_init(&task1,task1Entry,(void *)0x0,&task1Env[1024],8,3);
		task_init(&task2,task2Entry,(void *)0x0,&task2Env[1024],8,2);
		task_init(&task3,task3Entry,(void *)0x0,&task3Env[1024],8,1);

		task_startup(&task1);
		task_startup(&task2);
		task_startup(&task3);
	
		timer_start(&timer1);


    return 0;
}


